package cn.microservices.cloud.common.core.enums;

import java.util.Locale;

public enum GlobalizationLanguageEnums {
    ZH_CN("zh-CN", "中文(简体)", Locale.CHINA),
    ZH_TW("zh-TW", "中文(繁体)", Locale.CHINA),
    DE_DE("de-DE", "德语(德国)", Locale.GERMANY),
    EN_US("en-US", "英语(美国)", Locale.US),
    ES_ES("es-ES", "西班牙语(国际)", new Locale("es", "ES")),
    fr_FR("fr-FR", "法语(法国)", Locale.FRANCE),
    ja_JP("ja-JP", "日语", Locale.JAPAN);

    private static String pre_key = "microservices:globalization:language:%s";
    private static String defaultLanguage = "microservices:globalization:language:zh-CN";
    private String code;
    private String value;
    private Locale locale;

    public String getCode() {
        return String.format(pre_key, this.code);
    }

    public String getSimpleCode() {
        return this.code;
    }

    public String getValue() {
        return this.value;
    }

    public Locale getLocale() {
        return this.locale;
    }

    private GlobalizationLanguageEnums() {
    }

    private GlobalizationLanguageEnums(String code, String value, Locale locale) {
        this.code = code;
        this.value = value;
        this.locale = locale;
    }

    public static String getCodeFormatByCode(String code) {
        GlobalizationLanguageEnums[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            GlobalizationLanguageEnums globalizationEnums = var1[var3];
            if (code.equals(globalizationEnums.code)) {
                return globalizationEnums.getCode();
            }
        }

        return defaultLanguage;
    }

    public static Locale getLocaleByCode(String code) {
        GlobalizationLanguageEnums[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            GlobalizationLanguageEnums globalizationEnums = var1[var3];
            if (code.equals(globalizationEnums.code)) {
                return globalizationEnums.getLocale();
            }
        }

        return ZH_CN.locale;
    }

    public static String getValueByCode(String code) {
        GlobalizationLanguageEnums[] var1 = values();
        int var2 = var1.length;

        for(int var3 = 0; var3 < var2; ++var3) {
            GlobalizationLanguageEnums globalizationEnums = var1[var3];
            if (code.equals(globalizationEnums.code)) {
                return globalizationEnums.getValue();
            }
        }

        return defaultLanguage;
    }
}
